# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=birp
pkgver=65.b2e108a
pkgrel=6
pkgdesc='A tool that will assist in the security assessment of mainframe applications served over TN3270.'
groups=('blackarch' 'blackarch-scanner' 'blackarch-recon' 'blackarch-fuzzer')
arch=('any')
url='https://github.com/sensepost/birp'
license=('custom:unknown')
depends=('fontconfig' 'xorg-xset' 'xorg-mkfontscale' 'xorg-mkfontdir' 'python2'
         'python2-colorama' 'python2-py3270' 'python2-ipython-genutils' 'x3270'
         'python2-backports.functools_lru_cache' 'ipython2')
source=("git+https://github.com/sensepost/$pkgname.git"
        'py3270wrapper.py.patch'
        'LICENSE')
makedepends=('git')
sha512sums=('SKIP'
            '82f7c5854b1f7e9ae9c0d809ccb295c962e09f45d03c041de66e027f6cca9820b51f469ddb0ee5a91927b7fa113a55d25bae5daf231402566d33f3c39ed852bb'
            '5c0ff9ce5529f5c2d01cf25c296ccde75f056794c263765f0f652b809433c695d9836b58c5761a74494bcbb96747119bc914163dc706a9aad700d3351d688c71')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  patch -p1 < py3270wrapper.py.patch
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" Readme.md
  install -Dm 644 "../LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm Readme.md ../LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

